#
# Postil Nginx: Dockerfile building for Nginx images
#

FROM		docker.io/centos
MAINTAINER	renyongfanemail@sina.com

ADD aliyun-mirror.repo /etc/yum.repos.d/CentOS-Base.repo
ADD aliyun-epel.repo /etc/yum.repos.d/epel.repo

RUN yum -y install systemd systemd-libs net-tools && \
    yum install -y gcc gcc-c++ git make automake cmake patch logrotate python-devel libpng-devel libjpeg-devel && \
    yum -y install nginx php-cli php-mysql php-pear php-ldap php-mbstring php-soap php-dom php-gd php-xmlrpc php-fpm php-mcrypt && \ 
    yum -y install supervisor && \
    yum clean all

ADD supervisord.conf /etc/supervisord.conf

ADD nginx_nginx.conf /etc/nginx/nginx.conf
ADD nginx_default.conf /etc/nginx/conf.d/default.conf
RUN sed -i 's/user = apache/user = nginx/' /etc/php-fpm.d/www.conf 
RUN sed -i 's/group = apache/group = nginx/' /etc/php-fpm.d/www.conf

RUN mkdir -p /etc/supervisor.conf.d && \
    mkdir -p /var/log/supervisor

ADD supervisor_nginx.conf /etc/supervisor.conf.d/nginx.conf
ADD supervisor_php-fpm.conf /etc/supervisor.conf.d/php-fpm.conf

RUN	mkdir -p /app && echo "<?php phpinfo(); ?>" > /app/index.php

EXPOSE	80

ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]